﻿using System;
using System.Configuration;

namespace TSharp.Core.Mvc.XmlRouting
{
    /// <summary>
    ///     路由项
    ///     <para>2010/8/13</para>
    ///     <para>TANGJINGBO</para>
    ///     <para>tangjingbo</para>
    /// </summary>
    internal sealed class RoutingItem : ConfigurationElement
    {
        /// <summary>
        ///     路由名称
        /// </summary>
        /// <value>The name.</value>
        [ConfigurationProperty("name", IsRequired = true, IsKey = true)]
        public string Name
        {
            get { return this["name"].ToString(); }
        }

        /// <summary>
        ///     Gets the URL.
        /// </summary>
        /// <value>The URL.</value>
        [ConfigurationProperty("url", IsRequired = true, IsKey = true)]
        public string Url
        {
            get { return this["url"].ToString(); }
        }

        /// <summary>
        ///     Gets the controller.默认控制器
        /// </summary>
        /// <value>The controller.</value>
        [ConfigurationProperty("controller", IsRequired = true)]
        public string Controller
        {
            get
            {
                return this["controller"].ToString();
            }
        }

        /// <summary>
        ///     Gets the action.默认Action
        /// </summary>
        /// <value>The action.</value>
        [ConfigurationProperty("action", IsRequired = true)]
        public string Action
        {
            get { return this["action"].ToString(); }
        }

        /// <summary>
        ///     Gets the area.区域名称
        /// </summary>
        /// <value>The area.</value>
        [ConfigurationProperty("area", IsRequired = false)]
        public string Area
        {
            get
            {
                return this["area"].ToString();
            }
        }

        [ConfigurationProperty("namespaces", IsRequired = false)]
        public string Namespaces
        {
            get { return this["namespaces"].ToString(); }
        }

        /// <summary>
        ///     Gets the paramaters.默认参数
        /// </summary>
        /// <value>The paramaters.</value>
        [ConfigurationProperty("parameters", IsRequired = false)]
        public ParameterCollection Paramaters
        {
            get { return this["parameters"] as ParameterCollection; }
        }

        [ConfigurationProperty("afterCodeReg", IsRequired = false)]
        public bool IsAfterCodeReg
        {
            get { return Convert.ToBoolean(this["afterCodeReg"]); }
        }
    }
}